<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :md="4" :sm="4">
            <a-form-item :label="$t('systemManagement.project') ">
              <a-select v-model="queryParam.projectCode"  v-decorator="[ 'projectCode']" :placeholder="$t('base.pleaseChoose')">
                <a-select-option v-for="item in projectList" :key="item.id" :value="item.code">
                  {{item.name}}
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md="4" :sm="4">
            <a-form-item :label="$t('base.code')">
              <j-input :placeholder="$t('base.inputVagueQuery')" v-model="queryParam.code"></j-input>
            </a-form-item>
          </a-col>

          <a-col :md="4" :sm="4">
            <a-form-item :label="$t('base.name')">
              <j-input :placeholder="$t('base.inputVagueQuery')" v-model="queryParam.name"></j-input>
            </a-form-item>
          </a-col>

          <a-col :md="3" :sm="4">
            <a-form-item :label="$t('video.style')">
              <j-dict-select-tag  v-model="queryParam.equipmentStyleType" :placeholder="$t('base.pleaseChoose')" dictCode="glr_video_equipment_style_type"/>
            </a-form-item>
          </a-col>


          <a-col :md="4" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search"> {{$t('base.query')}} </a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px"> {{$t('base.reset')}} </a-button>
            </span>
          </a-col>


        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus"> {{$t('base.add')}} </a-button>
      <a-button @click="batchDel" type="primary" icon="delete"> {{$t('base.del')}} </a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> {{$t('base.selected')}} <a style="font-weight: 600">{{ selectedRowKeys.length }}</a> {{$t('base.item')}}
        <a style="margin-left: 24px" @click="onClearSelected"> {{$t('base.clear')}} </a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{fixed:true,selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        
        @change="handleTableChange">
        <template slot="avatarslot" slot-scope="text, record, index">
          <div class="anty-img-wrap">
            <img :src="getAvatarView(record.equipmentStatus)"/>
          </div>
        </template>

        <template slot="avatarslot1" slot-scope="text, record, index">
          <label v-html="record.glrVideoYs.code"/>
          -
          <label v-html="record.glrVideoYs.name"/>
        </template>




        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)"> {{$t('base.edit')}} </a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link"> {{$t('base.more')}} <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm  :title="$t('base.confirmDelete')" @confirm="() => handleDelete(record.id)">
                  <a> <a-icon type="delete" /> {{$t('base.del')}} </a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <glrVideo-modal ref="modalForm" @ok="modalFormOk"></glrVideo-modal>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import GlrVideoModal from './modules/GlrVideoModal'
  import JInput from '@/components/jeecg/JInput'
  import { httpAction } from '@/api/manage'
  export default {
    name: "GlrVideoList",
    mixins:[JeecgListMixin],
    components: {
      GlrVideoModal,
      JInput
    },
    data () {
      return {
        description: this.$t('video.cameraManagement') ,
        imagstr:"/assets/guaz.png",
        projectList:[],
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title: this.$t('base.code'),
            align:"center",
            dataIndex: 'code'
          },
          {
            title: this.$t('base.name') ,
            align:"center",
            dataIndex: 'name'
          },
          {
            title:this.$t('video.equipmentModel') ,
            align:"center",
            dataIndex: 'equipmentModel'
          },
          {
            title:this.$t('video.equipmentSerial'),
            align:"center",
            dataIndex: 'equipmentSerial'
          },
          {
            title: this.$t('base.status'),
            align:"center",
            scopedSlots: {customRender: "avatarslot"}
          },
          {
            title: this.$t('video.equipmentStyleType'),
            align:"center",
            dataIndex: 'equipmentStyleType_dictText'
          },
          {
            title:this.$t('video.equipmentFunctionType') ,
            align:"center",
            dataIndex: 'equipmentFunctionType_dictText'
          },
          {
            title:this.$t('video.belongingYS') ,
            align:"center",
            scopedSlots: {customRender: "avatarslot1"}
          },
          {
            title: this.$t('base.operation'),
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/glr/glrVideo/list",
          delete: "/glr/glrVideo/delete",
          deleteBatch: "/glr/glrVideo/deleteBatch",
          exportXlsUrl: "/glr/glrVideo/exportXls",
          importExcelUrl: "glr/glrVideo/importExcel",
          getProjectList: "/glr/glrProject/getProject",
        },
        dictOptions:{
        },
      }
    },
    created(){
      const that = this;
      httpAction(that.url.getProjectList,{},"post").then((res)=>{
        if(res.success){
          that.projectList=res.result;
        }else{
          that.$message.warning(res.message);
        }
      }).finally(() => {
        that.confirmLoading = false;
      })
      //this.loadData();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      initDictConfig(){
      },
      getAvatarView: function (equipmentStatus) {
        if(equipmentStatus=='Y'){
          return   require('@/assets/img/zaixian.png');
        }else{
          return   require('@/assets/img/lixian.png');
        }
      },
       
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>